package me.littlesquid.bettertp;


import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.Collection;

public class gui {
    public static void ergodic(Inventory inventory){
        Collection<? extends Player> playerlist=Bukkit.getServer().getOnlinePlayers();
        int i=10;
        for(Player player:playerlist){
            ItemStack itemStack=new ItemStack(head.getHead(player));
            ItemMeta itemMeta=itemStack.getItemMeta();
            itemMeta.setDisplayName(player.getDisplayName());
            itemStack.setItemMeta(itemMeta);
            inventory.setItem(i,itemStack);
            if(i>9&&i<44){
                if(i % 9==0||(i+1)%9==0){
                    i=i+3;
                }else {
                    i=i+1;
                }
            }
        }

    }
    public static Inventory open(){
        Inventory inventory= Bukkit.createInventory(null,6*9,"传送菜单");
        ItemStack glass = new ItemStack(Material.LIME_STAINED_GLASS_PANE);
        ItemMeta g = glass.getItemMeta();
        g.setDisplayName(ChatColor.GOLD + "欢迎使用");
        glass.setItemMeta(g);
        ItemStack death=new ItemStack(Material.BONE);
        ItemMeta d= death.getItemMeta();
        d.setDisplayName("返回死亡点");
        death.setItemMeta(d);
        ItemStack home=new ItemStack(Material.RED_BED);
        ItemMeta h=home.getItemMeta();
        h.setDisplayName("返回出生点");
        home.setItemMeta(h);
        ItemStack back=new ItemStack(Material.ACACIA_SIGN);
        ItemMeta b= back.getItemMeta();
        b.setDisplayName("返回上一次传送");
        back.setItemMeta(b);
        inventory.setItem(0,glass);
        inventory.setItem(1,death);
        inventory.setItem(2,glass);
        inventory.setItem(3,home);
        inventory.setItem(4,glass);
        inventory.setItem(5,back);
        inventory.setItem(6,glass);
        inventory.setItem(7,glass);
        inventory.setItem(8,glass);
        inventory.setItem(9,glass);
        inventory.setItem(17,glass);
        inventory.setItem(18,glass);
        inventory.setItem(26,glass);
        inventory.setItem(27,glass);
        inventory.setItem(35,glass);
        inventory.setItem(36,glass);
        inventory.setItem(44,glass);
        inventory.setItem(45,glass);
        inventory.setItem(46,glass);
        inventory.setItem(47,glass);
        inventory.setItem(48,glass);
        inventory.setItem(49,glass);
        inventory.setItem(50,glass);
        inventory.setItem(51,glass);
        inventory.setItem(52,glass);
        inventory.setItem(53,glass);
        ergodic(inventory);
        return inventory;
    }
}
